package esms.action.helper;

import org.apache.log4j.Logger;

import com.thoughtworks.selenium.DefaultSelenium;

import esms.action.ActionInterface;
import esms.manager.RunTimeContext;
import esms.manager.SeleniumManager;


/**
 * Open the browser and add it to the RunTimeContext
 * @author Carol
 *
 */
public class InitBrowser implements ActionInterface {
	private String url;
	private String browserType;
	private String timeOut;
	private String key;
	private static Logger log = Logger.getLogger("InitBrowserAction");
	
	public InitBrowser(String url, String browserType, String timeOut,String key) {
		this.url = url;
		this.browserType = browserType;
		this.timeOut = timeOut;
		this.key = key;
	}

	public void execute(DefaultSelenium sele) { 
		DefaultSelenium selenium = SeleniumManager.createSeleniumClient(this.browserType,
				this.url);
		selenium.start();
		selenium.setTimeout(this.timeOut);
		
		//add this selenium to a run time zone to use when processing 
		RunTimeContext.addBrowser(this.key, selenium);
		
		log.info("Start browser:" + this.url);
	}

}
